﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Micronet.OpenWeb.Com.BLL;
using Micronet.OpenWeb.Com.Controls;
using Micronet.OpenWeb.Utils;

namespace Micronet.OpenWeb.OpenWeb.Admin.Views.Shared.OpenCommunity
{
    public partial class CommunityFieldOfActivitiesAdmin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void IsHot_CheckedChanged(object sender, EventArgs e)
        {

            var isHotCheckBox = (OwCheckBox)sender;
            var obj = OwCommunityFieldOfActivitiesBLL.OwGetEntity(isHotCheckBox.Text.Trim().OwToInt64TryParse());

            obj.IsHot = isHotCheckBox.Checked.ToString().OwToBoolean();
            if (OwCommunityFieldOfActivitiesBLL.OwSave(obj) > 0)
            {
                CommunityFieldOfActivitiesGrid.Rebind();

            }

        }

        protected void IsApprovedCb_CheckedChanged(object sender, EventArgs e)
        {

            var isApprovedCheckBox = (OwCheckBox)sender;
            var obj = OwCommunityFieldOfActivitiesBLL.OwGetEntity(isApprovedCheckBox.Text.Trim().OwToInt64TryParse());

            obj.IsApproved = isApprovedCheckBox.Checked.ToString().OwToBoolean();
            if (OwCommunityFieldOfActivitiesBLL.OwSave(obj) > 0)
            {
                CommunityFieldOfActivitiesGrid.Rebind();

            }

        }

        protected void IsHomeDisplayCb_CheckedChanged(object sender, EventArgs e)
        {

            var isHomeDisplayCheckBox = (OwCheckBox)sender;
            var obj = OwCommunityFieldOfActivitiesBLL.OwGetEntity(isHomeDisplayCheckBox.Text.Trim().OwToInt64TryParse());

            obj.IsHomeDisplay = isHomeDisplayCheckBox.Checked.ToString().OwToBoolean();
            if (OwCommunityFieldOfActivitiesBLL.OwSave(obj) > 0)
            {
                CommunityFieldOfActivitiesGrid.Rebind();

            }

        }

        protected void IsDeleted_CheckedChanged(object sender, EventArgs e)
        {

            var isDeletedCheckBox = (OwCheckBox)sender;
            var obj = OwCommunityFieldOfActivitiesBLL.OwGetEntity(isDeletedCheckBox.Text.Trim().OwToInt64TryParse());

            obj.IsDeleted = isDeletedCheckBox.Checked.ToString().OwToBoolean();
            if (OwCommunityFieldOfActivitiesBLL.OwSave(obj) > 0)
            {
                CommunityFieldOfActivitiesGrid.Rebind();

            }

        }

        protected void IsEnabledCb_CheckedChanged(object sender, EventArgs e)
        {

            var isEnabledCbCheckBox = (OwCheckBox)sender;
            var obj = OwCommunityFieldOfActivitiesBLL.OwGetEntity(isEnabledCbCheckBox.Text.Trim().OwToInt64TryParse());

            obj.IsEnabled = isEnabledCbCheckBox.Checked.ToString().OwToBoolean();
            if (OwCommunityFieldOfActivitiesBLL.OwSave(obj) > 0)
            {
                CommunityFieldOfActivitiesGrid.Rebind();

            }

        }




    }
}